import {mapGetters, mapMutations} from "vuex";
import MetaUtils from "@/utils/MetaUtils";

export default {
    computed: {
        ...mapGetters([
            'editMetas'
        ]),
        activeClass() {
            return this.meta.active ? 'ivz-item-active' : 'ivz-item-inactivation';
        }
    },
    methods: {
        ...mapMutations([
            'switchPathTo',
            'switchActiveMetaTo',
            'setTableTabMetas',
            'setListTabMetas',
            'setSearchTabMetas',
            'switchEditVisible'
        ]),
        activeMetaTo() {
            if(this.meta) {
                this.switchActiveMetaTo(this.meta);
            } else {
                console.warn('未注入组件元对象[meta]');
            }
        },
        toggleMetaToEdit(meta) {
            let metaById = MetaUtils.getMetaById(this.editMetas, meta.id);
            if(metaById) {
                this.switchActiveMetaTo(metaById)
                this.switchEditVisible(true);
            }
        }
    }
}